package emulator.hardware.nmos6502.commands;

import emulator.EmulatorException;
import emulator.hardware.nmos6502.Command;
import emulator.hardware.nmos6502.CommandSet;
import emulator.hardware.nmos6502.Cpu6502;
import emulator.hardware.nmos6502.Operand;
import emulator.hardware.nmos6502.operands.Absolute;
import emulator.hardware.nmos6502.operands.ZeroPage;
import emulator.hardware.nmos6502.operands.ZeroPageY;

/** STX (STore X register)
 *  
 *  Affects Flags: none
 *  
 *  MODE           SYNTAX       HEX LEN TIM
 *  Zero Page     STX $44       $86  2   3
 *  Zero Page,Y   STX $44,Y     $96  2   4
 *  Absolute      STX $4400     $8E  3   4
 */
public class STX implements Command {

	@Override
	public void execute(Cpu6502 cpu, Operand operand) throws EmulatorException {
		operand.setByte(cpu.getX());
	}

	@Override
	public String getName() {
		return "STX";
	}

	@Override
	public void register(CommandSet cset) {
		 cset.defineCommand(0x86, this, new ZeroPage());
		 cset.defineCommand(0x96, this, new ZeroPageY());
		 cset.defineCommand(0x8E, this, new Absolute());
	}

}
